﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Benlai.Dac.Mongo;
using MongoDB.Driver;
using Benlai.Model.Common;

namespace Benlai.Dac.Common
{
    public class NavigationDac : MongoHandler<NavigationModel>
    {
        public NavigationDac()
        {
            DBName = "houtai";
            Name = "Navigation";
            SortPropertyName = "ordernum";
            IsDescending = false;
        }

        public NavigationModel GetByID(string id)
        {
            return FindByID(id);
        }

        public List<NavigationModel> Get(string no)
        {
            return GetModel(new { no = no }).ToList<NavigationModel>();
        }

        public void Set(NavigationModel model)
        {
            if (string.IsNullOrEmpty(model.Id))
            {
                Insert(model);
            }
            else
            {
                Update(model, model.Id);
            }
        }

        public List<NavigationModel> GetList(int pageIndex, int pageSize, out int recordCount)
        {
            return GetModel(pageIndex, pageSize, out recordCount).ToList<NavigationModel>();
        }
    }
}
